$(document).ready(function() {

    //搜索职位 & 搜索员工
    $('.search_name').autocomplete({
        source: function(request, response) {
            var rd = $('input:radio[name=optionsRadios]:checked').val();

            $.ajax({
                url: rd == 1 ? ajaxUrl2 : ajaxUrl,
                dataType: "json",
                data: {
                    name: request.term
                },
                success: function(data) {
                    response( $.map( data.data, function( item ) {
                        return {
                            label: rd == 1 ? item.job_name : item.name,
                            value: rd == 1 ? item.job_name : item.name,
                            //id: rd == 1 ? item.job_id : item.user_id
                            userid : rd == 1 ? '' : item.user_id,
                            jobid : item.job_id
                        }
                    }));
                }
            });
        },
        select: function( event, ui ) {
            var rd = $('input:radio[name=optionsRadios]:checked').val();
            //var id = rd == 1 ? ui.item.job_id : ui.item.id;
            var userid = ui.item.userid,
                jobid = ui.item.jobid;

            var input1 = $(this).parent().find('input[type="hidden"]')[0];
            var input2 = $(this).parent().find('input[type="hidden"]')[1];

            input1.value = rd == 1 ? '' : userid;
            input2.value = jobid;
        }
    })

    $("input[type='checkbox']").bind('click',function(){
        var num =  $("input[type='checkbox']:checked").length;
        num >0 ? $(".dL").css("visibility","visible"):$(".dL").css("visibility","hidden");

    });
    $("#form-content").find("input[type='submit']").bind('click',function(){
        if(!$.trim($(".search_name.span2.ui-autocomplete-input").val())){
            return false;
        }

    });


});



